package com.jiyang.jyandroid;

import android.app.LauncherActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;

import com.jiyang.jyandroid.test01.One_1Activity;
import com.jiyang.jyandroid.test01.One_2Activity;
import com.jiyang.jyandroid.test01.One_3Activity;
import com.jiyang.jyandroid.test01.One_4Activity;
import com.jiyang.jyandroid.test01.One_5Activity;
import com.jiyang.jyandroid.test01.One_6Activity;
import com.jiyang.jyandroid.test01.One_7Activity;
import com.jiyang.jyandroid.test01.One_8Activity;
import com.jiyang.jyandroid.test02.Two_1Activity;
import com.jiyang.jyandroid.test02.Two_2Activity;
import com.jiyang.jyandroid.test02.Two_3Activity;
import com.jiyang.jyandroid.test02.Two_4Activity;
import com.jiyang.jyandroid.test02.Two_5Activity;
import com.jiyang.jyandroid.test02.Two_6Activity;
import com.jiyang.jyandroid.test03.Three_2Activity;
import com.jiyang.jyandroid.test03.Three_3Activity;
import com.jiyang.jyandroid.test04.Four_1and3Activity;
import com.jiyang.jyandroid.test05.Five_1Activity;
import com.jiyang.jyandroid.test05.Five_2Activity;
import com.jiyang.jyandroid.test06.Six_1Activity;
import com.jiyang.jyandroid.test06.Six_2Activity;

public class MainActivity extends LauncherActivity {
    private Intent intent;
    private Class<?>[] activityClass;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Toast.makeText(this, getResources().getString(R.string.app_name), Toast.LENGTH_SHORT).show();
        String[] activityNames = getResources().getStringArray(R.array.activity_name);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, activityNames);
        setListAdapter(adapter);
        activityClass = new Class[]{
                One_1Activity.class,
                One_2Activity.class,
                One_3Activity.class,
                One_4Activity.class,
                One_5Activity.class,
                One_6Activity.class,
                One_7Activity.class,
                One_8Activity.class,
                Two_1Activity.class,
                Two_2Activity.class,
                Two_3Activity.class,
                Two_4Activity.class,
                Two_5Activity.class,
                Two_6Activity.class,
                Three_2Activity.class,
                Three_3Activity.class,
                Four_1and3Activity.class,
                Five_1Activity.class,
                Five_2Activity.class,
                Six_1Activity.class,
                Six_2Activity.class
        };
        intent = new Intent();
    }

    @Override
    protected Intent intentForPosition(int position) {
        if (position >= activityClass.length) {
            Toast.makeText(MainActivity.this, "该界面还未实现", Toast.LENGTH_SHORT).show();
            intent.setClass(MainActivity.this, MainActivity.class);
            return intent;
        }
        intent.setClass(MainActivity.this, activityClass[position]);
        return intent;
    }
}
